<template>
	<view class="mainbgc">
		<header-top :messageInfo="{typeFlag:true,message:titletext}"></header-top>
		<!-- <view class="flexcenter" v-if="!newdate.length">
			<view class="placeholderimg"></view>
		</view> -->
		<view class="ffffff flexbetween strongtext mainpadding">
			<view class="inputsearch">
				<input type="text" placeholder="请输入搜索内容" v-model="keywords" confirm-type="search" @confirm="init">
			</view>
			<view class="focus" @click="init">搜索</view>
		</view>
		<view class="allnews">
			<view class="itemnews ffffff mainpadding margin_top"
				@click="jumpurl(item.id)" v-for="item in list.data" :key="item.id">
				<view class="right-content flexbetween">
					<view class="bottext">{{item.title}}</view>
					<view class="toptext">{{item.createtime_text}}</view>
				</view>
				<view class="margin_top toptext">{{item.des}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				type:1,
				titletext:"",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				keywords:""
			}
		},
		onLoad(options) {
			this.type = options.type
			if(options.type==1){
				this.titletext = "政策发文"
			}
			if(options.type==2){
				this.titletext = "公司制度"
			}
			if(options.type==3){
				this.titletext = "最新通知"
			}
			if(options.type==4){
				this.titletext = "常见问题"
			}
			this.init()
		},
		methods: {
			jumpurl(id){
				uni.navigateTo({
					url:"/pages/xiaoxixq/xiaoxixq?id=" + id
				})
			},
			// 热门推荐列表
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/employeesapi/index/getPtNotice', 'POST', {
					page: page || 1,
					limit: _this.limit,
					type:this.type,
					keywords:this.keywords,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = resList
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.leftimage {
		width: 106rpx;
		height: 106rpx;
		border-radius: 50%;
		margin-right: 30rpx;
		background-color: #F6F6F6;
		flex: 1.5;
	}

	.imagekf {
		width: 61rpx;
		height: 59rpx;
	}

	.right-content {
		width: 100%;
		flex: 8;
		box-sizing: border-box;
	}

	.toptext {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.bottext {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #000000;
		width: 300rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.dian{
		width: 15rpx;
		height: 15rpx;
		background-color: #ff0000;
		border-radius: 50%;
	}
</style>
